import type { SysTenantWalletRecord } from '..';

import type { BaseEntity, PageQuery, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

const baseUrl = `/ur_biz/tenant_profile`;

/**
 * 租户信息
 */
export interface SysTenantProfile extends BaseEntity {
  name: string;
  type: string;
  contactPhone: number;
  status: number;
  domain: string;
  expireTime: string;
  accountLimit: string;
  roleLimit: string;
  postLimit: string;
  deptLimit: string;
}

/**
 * 租户使用额度
 */
export interface SysTenantUsedQuota {
  accountHas: number;
  roleHas: number;
  postHas: number;
  deptHas: number;
}

/**
 * 钱包信息
 */
export interface WalletInfo {
  balance: string;
  status: string;
}

/**
 *
 * @returns 获取租户信息
 */
export function getProfile() {
  return requestClient.get<SysTenantProfile>(`${baseUrl}`);
}

/**
 * 已使用的额度
 */
export function getUsedQuota() {
  return requestClient.get<SysTenantUsedQuota>(`${baseUrl}/used_quota`);
}

/**
 *
 * @returns 获取钱包信息
 */
export function getWalletInfo() {
  return requestClient.get<WalletInfo>(`${baseUrl}/wallet_info`);
}

/**
 *
 * @returns 钱包记录
 */
export function listWalletRecord(query?: PageQuery) {
  return requestClient.get<PageResult<SysTenantWalletRecord>>(
    `${baseUrl}/wallet_record/list`,
    { params: query },
  );
}

/**
 *
 *  修改操作密码
 */
export function editOperPwd(data: any) {
  return requestClient.post(`${baseUrl}/edit_operpwd`, { data });
}

/**
 *
 * 提现
 */
export function withdrawal(data: any) {
  return requestClient.post(`${baseUrl}/wallet/withdrawal`, { data });
}
